import time

from appium import webdriver
from selenium.webdriver.support.ui import WebDriverWait

cap = {
  "platformName": "Android",
  "platformVersion": "5.1.1",
  "deviceName": "127.0.0.1:62001",
  "appPackage": "com.xingin.xhs",
  "appActivity": "com.xingin.xhs.activity.SplashActivity",
  "noReset": True
}
def getSize():
    x = driver.get_window_size()['width']
    y = driver.get_window_size()['height']
    return (x,y)

driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub',cap)
if WebDriverWait(driver,3).until(lambda x:x.find_element_by_id("com.xingin.xhs:id/e3e")):
    driver.find_element_by_id("com.xingin.xhs:id/e3e").click()
if WebDriverWait(driver,3).until(lambda x:x.find_element_by_id("com.xingin.xhs:id/cmk")):
    driver.find_element_by_id("com.xingin.xhs:id/cmk").send_keys("jk")
if WebDriverWait(driver,3).until(lambda x:x.find_element_by_id("com.xingin.xhs:id/cmo")):
    driver.find_element_by_id("com.xingin.xhs:id/cmo").click()
l = getSize()
x1 = int(l[0]*0.5)
y1 = int(l[1]*0.75)
y2 = int(l[1]*0.25)
while True:
    driver.swipe(x1,y1,x1,y2)
    time.sleep(1)

